﻿<?php
// ----------------------------------------------------------------------------
//
//  File: poll_list.php   
//  Creation Date:  06/09/11
//  Last Modified:  06/09/11
//  Purpose: 投票列表
//
// ----------------------------------------------------------------------------
?>
<?php
require_once("action/sys_conf.inc");
$link_id = mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME);
mysql_query("SET NAMES 'utf8'");
$sql = "select id,subject,createTime,modifyTime from extpollsubject order by id desc";
$result = mysql_query($sql);
?>
<script language="JavaScript" type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript">
function delPoll(scope,idx){			
	$.ajax({
		url:	'action/del.php',
		data: "scope="+scope+"&idx="+idx,					
		success: function(){
			alert( "删除成功！" );
			$("#"+scope+"_"+idx).remove();
			if($("#table_"+scope+" tr:last-child").is(":first-child")){
				$("#table_"+scope).remove();
			}					 
		},
		error:	function(){
			alert( "删除失败！" );
		}
	});			
}
</script>
<table width="80%" border="0">
  <tr>
    <td><a href="poll_add.php">添加投票</a></td>
  </tr>
<?php 
	if(!mysql_num_rows($result)){
		echo "Sorry,目前没有数据";
		exit;
	}
	else{
?>
  <tr>
    <td><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" id="table_poll">
  <tr>
    <th scope="col">序号</th>
		<th scope="col">投票主题</th>
		<th scope="col">发布时间</th>
		<th scope="col">更新时间</th>
		<th scope="col">操作</th>
  </tr>
	<?php
		while($poll = mysql_fetch_assoc($result)){ 
			$id = $poll[id];
			$subject = $poll[subject];
			$createTime = $poll[createTime];
			$modifyTime = $poll[modifyTime];
	?>	
  <tr align="center" id="poll_<?php echo $id ?>" class="poll">
    <td><?php echo $id ?></td>
		<td><?php echo $subject ?></td>
		<td><?php echo $createTime ?></td>
		<td><?php echo $modifyTime ?></td>
		<td><a href="poll_add.php?id=<?php echo $id  ?>">编辑</a>&emsp;&emsp;<a href="javascript:void(0)" onclick="javascript:delPoll('poll',<?php echo $id ?>)">删除</a></td>
  </tr>
	<?php }} ?>
</table>
</td>
  </tr>
</table>
